package cnsukidayo.com.gitee.utils;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

/**
 * 保存和获取当前用户的工具类
 */
public class UserContextUtils {
    private static final String CURRENT_USER_IN_SESSION = "token";

    /**
     * 得当当前用户的token
     */
    public static String getToken(HttpServletRequest httpServletRequest) {
        String token = "";
        for (Cookie cookie : httpServletRequest.getCookies()) {
            if (cookie.getName().equals("token")) {
                token = cookie.getValue();
            }
        }
        return token;
    }

}
